import random

def get_randlist_int(minnum, maxnum, length):
    templist = list()
    for x in range(length):
        newnum = random.randint(minnum, maxnum)
        templist.append(newnum)
    return templist

def get_randlist_float(minnum, maxnum, length, roundnum=2):
    templist = list()
    for x in range(length):
        newnum = random.uniform(minnum, maxnum)
        templist.append(round(newnum,roundnum))
    return templist

# 数字补0: get_format_numstr('3')-->'03'
def get_format_numstr(numstr):
    return numstr.zfill(2)          # 补到十位数--方式1
    # return '%02d'%int(numstr)     # 补到十位数--方式2


if __name__ == '__main__':
    print(get_randlist_float(0,10,20))
    print(get_format_numstr('3'))

    
